<template>
  <div class="container">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page"
      :pageSizes="pageSizes"
      :pageSize="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>
<script>
export default {
  // 16.1 子组件接收
  // props: ['page','pageSize','total','pageSize'],       //16.2在传回给父组件
  // 16.3改写16.1
  props:{
    page:{
      default(){return 1},
      type:Number},
      pageSize:{
      default(){return 20},
      type:Number},
      total:{
      default(){return 0},
      type:Number},
      pageSizes:{
      default(){return [10,20,30,40]},
      type:Array()},
  },
  
  methods: {
    handleSizeChange(val) {
      // 控制每一页显示多少条
      console.log(`每页 ${val} 条`);
      // 17.1
      this.$emit('changepageSize',val)       //父组件中接收
    },
    handleCurrentChange(val) {
      // 控制当前页码
      console.log(`当前页: ${val}`);
      this.$emit('changePage',val)
    }
  },
  data() {
    return {
      // 控制页面当前显示哪一页
      currentPage4: 1
    };
  }
};
</script>
<style lang='less' scoped>
.container {
  height: 60px;
  display: flex;
  align-items: center;
  // 位置居右
  justify-content: right;
}
</style>
 